import localStorage from '../utils/localStorage'
export default {
  state: {
    Firstbread: [],
    Secondbread: []
  },
  mutations: {
    activeTabMutations(state, param) {
      const adminRules = localStorage.get('rules', true)

      if (param === undefined) return

      // 获取二级栏目
      const secondbread = adminRules.filter(value => {
        return value.id === param.id
      })

      if (state.Secondbread.id !== secondbread[0].id) {
        state.Secondbread = secondbread[0] // 二级栏目对象
      }

      // 获取一级栏目
      const firstbread = adminRules.filter(value => {
        return value.id === param.pid
      })

      if (state.Firstbread.id !== firstbread[0].id) {
        state.Firstbread = firstbread[0] // 一级栏目对象
      }
    }
  }
}
